package main.java.Thread;

public class Thread3 {
    public static void main(String[] args) throws InterruptedException {
        int j  = 0 ;
        Thread t = new Thread(new t1());
        t.start();
        while (j < 20){
            System.out.println("主线程" + ++j);
            Thread.sleep(1000);
            if (j == 4){
                t.join();
            }
        }
    }

}

class t1 implements Runnable{
    int i = 0;
    @Override
    public void run() {
        while (i <= 20){
            System.out.println("子线程安排" + ++i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
